<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>添加-员工管理</title>
		<!-- Bootstrap core CSS -->
		<link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.5.0/css/bootstrap.css}" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="asserts/css/dashboard.css" th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
		<style type="text/css">
			/* Chart.js */
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			.chartjs-render-monitor {
				-webkit-animation: chartjs-render-animation 0.001s;
				animation: chartjs-render-animation 0.001s;
			}
		</style>
	</head>

	<body>

		<!-- 引入抽取的 topbar 模板
		  模板名: 会使用 thymeleaf 的前后缀配置规则进行解析
		 -->
		<div th:replace="commons/bar :: topbar"></div>

		<div class="container-fluid">
			<div class="row">
				<!-- 引入 sidebar -->
				<div th:replace="commons/bar :: #sidebar(activeUri='emps')"></div>

				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<!--需要区分是员工修改还是添加-->
					<form th:action="@{/emp}" method="post">
						<!--
						发送 put 请求修改员工数据
						1. SpringMVC 中配置 hiddenHttpMethodFilter ; (Spring Boot 已经自动配置)
						2. 页面创建一个 post 表单
						3. 添加一个 name="_method" 的 input 项, 值就是我们指定的请求方式
						-->
						<input type="hidden" name="_method" value="put" th:if="${emp != null}" >
						<input type="hidden" name="id"  th:if="${emp != null}" th:value="${emp.id}" >

						<div class="form-group">
							<label for="lashName">LashName</label>
							<input type="text" name="lastName" class="form-control" id="lashName"  placeholder="请输入" th:value="${emp.lastName}">
						</div>

						<div class="form-group">
							<label for="exampleFormControlInput1">Email address</label>
							<input type="email" name="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com" th:value="${emp.email}">
						</div>
						<div class="form-group">
							<label >Gender</label>
							<div class="form-check form-check-inline">
								<input class="form-check-input" type="radio" name="gender" id="inlineRadio1" value="1" th:checked="${emp.gender} == 1 ? true: false">
								<label class="form-check-label" for="inlineRadio1">男</label>
							</div>
							<div class="form-check form-check-inline">
								<input class="form-check-input" type="radio" name="gender" id="inlineRadio2" value="2" th:checked="${emp.gender} == 2 ? true: false">
								<label class="form-check-label" for="inlineRadio2">女</label>
							</div>
						</div>
						<div class="form-group">
							<label for="exampleFormControlSelect1">Department</label>
							<select class="form-control" id="exampleFormControlSelect1" name="department.id">
								<option th:each="dept : ${depts}" th:value="${dept.id}" th:text="${dept.departmentName}" th:selected="${emp.department.id} == ${dept.id} ? true : false" >1</option>
							</select>
						</div>

						<div class="form-group">
							<label for="Birth">Birth</label>
							<input type="text" name="birth" class="form-control" id="Birth"  placeholder="请输入" th:value="${#dates.format(emp.birth, 'yyyy-MM-dd HH:mm')}">
						</div>

						<button type="submit" class="btn btn-primary">Submit</button>
					</form>
				</main>
			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js" th:src="@{/webjars/jquery/3.5.1/jquery.slim.js}"></script>
		<script type="text/javascript" src="asserts/js/popper.min.js" th:src="@{/webjars/popper.js/1.16.0/popper.js}" ></script>
		<script type="text/javascript" src="asserts/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/4.5.0/js/bootstrap.js}"></script>

		<!-- Icons -->
		<script type="text/javascript" src="asserts/js/feather.min.js" th:src="@{/asserts/js/feather.min.js}"></script>
		<script>
			feather.replace()
		</script>

		<!-- Graphs -->
		<script type="text/javascript" src="asserts/js/Chart.min.js" th:src="@{/asserts/js/Chart.min.js}"></script>
		<script>
			var ctx = document.getElementById("myChart");
			var myChart = new Chart(ctx, {
				type: 'line',
				data: {
					labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
					datasets: [{
						data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
						lineTension: 0,
						backgroundColor: 'transparent',
						borderColor: '#007bff',
						borderWidth: 4,
						pointBackgroundColor: '#007bff'
					}]
				},
				options: {
					scales: {
						yAxes: [{
							ticks: {
								beginAtZero: false
							}
						}]
					},
					legend: {
						display: false,
					}
				}
			});
		</script>

	</body>

</html>